﻿<Page
    x:Class="wToggl.TimeEntryDetailPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:wToggl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.BottomAppBar>
        <CommandBar ClosedDisplayMode="Compact">
            <CommandBar.PrimaryCommands>
                <AppBarButton Name="BackButton" Click="BackButton_OnClick" Icon="Back" Label="Back" />
                <AppBarButton Name="ChangeTimeButton" Click="ChangeTimeButton_OnClick" Icon="Calendar" Label="Pick time" />
                <AppBarButton Name="SaveChangesButton" Click="SaveChangesButton_OnClick" Icon="Save" Label="Save" />
            </CommandBar.PrimaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
    <ScrollViewer>
        <Grid x:Name="LayoutRoot">

            <Grid.ChildrenTransitions>
                <TransitionCollection>
                    <EntranceThemeTransition/>
                </TransitionCollection>
            </Grid.ChildrenTransitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <local:BackgroundWorkOverlay OverlayMessage="Loading entry..." Grid.RowSpan="2" Canvas.ZIndex="10" IsVisible="{Binding IsLoading}"/>

            <!-- Title Panel -->
            <StackPanel Grid.Row="0" Margin="19,0,0,0">
                <TextBlock Text="Toggly" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,12,0,0"/>
                <TextBlock Text="entry details" Margin="0,-6.5,0,26.5" Style="{ThemeResource HeaderTextBlockStyle}" CharacterSpacing="{ThemeResource PivotHeaderItemCharacterSpacing}"/>
            </StackPanel>

            <!--TODO: Content should be placed within the following grid-->
            <Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,9.5,19,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBox Grid.Row="0" Text="{Binding EntryDescription, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Description"/>

                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock HorizontalAlignment="Stretch" Style="{StaticResource BodyTextBlockStyle}" Text="Start:"/>
                    <TextBlock Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Entry.Start}"/>
                </Grid>

                <Grid Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock HorizontalAlignment="Stretch" Style="{StaticResource BodyTextBlockStyle}" Text="End:"/>
                    <TextBlock Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Entry.End}"/>
                </Grid>

                <Grid Grid.Row="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock HorizontalAlignment="Stretch" Style="{StaticResource BodyTextBlockStyle}" Text="Duration:"/>
                    <TextBlock Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Entry.DurationString}"/>
                </Grid>

                <local:TagSelector Header="Project" IsMultiSelect="False" Grid.Row="4" PlaceholderText="Select a project" Items="{Binding Projects}" SelectedItems="{Binding SelectedProjects, Mode=TwoWay}">
                    <local:TagSelector.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Name}"/>
                        </DataTemplate>
                    </local:TagSelector.ItemTemplate>
                </local:TagSelector>

                <local:TagSelector Header="Tags" PlaceholderText="Select tags" Grid.Row="5" Items="{Binding Tags}" SelectedItems="{Binding SelectedTags, Mode=TwoWay}">
                    <local:TagSelector.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Name}"/>
                        </DataTemplate>
                    </local:TagSelector.ItemTemplate>
                </local:TagSelector>
            </Grid>
        </Grid>
    </ScrollViewer>
    
</Page>
